<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据转化</title>
</head>

<body>
  <script>
    var fun = function () {

    }
    var param = 100
    // var param = 100.2
    // var param = "100"
    // var param = "张三"
    // var param = undefined
    // var param = fun
    getVarInfo(param)
    

    function getVarInfo(params) {
      if (typeof params == "number") {
        alert("变量的类型是--》数字")
        if (Number.parseInt(params) == params) {
          alert("是整数")
        } else {
          alert("是小数")
        }
      }
      if (typeof params == "string") {
        alert("变量的类型是--》字符串")
        if (Number.parseInt(params) == params) {
          alert("可以变成整数")
        } else {
          alert("你不可以变成整数")
        }
      }
      if (typeof params == "function") {
        alert("变量的类型是--》函数")
      }
      // console.log(typeof params)
      if (typeof params == "undefined") {
        alert("变量的类型是--》undefined没有定义")
      }
    }
  </script>
</body>

</html>